Wheel factorization is a graphical method for manually performing a preliminary to the Sieve of Eratosthenes that separates prime numbers from composites. Start by writing the natural numbers around circles as shown below. Prime numbers in the innermost circle have their multiples in similar positions as themselves in the other circles, forming spokes of primes and their multiples. Multiples of the prime numbers in the innermost circle form spokes of composite numbers in the outer circles.
Contents |
1. Find the first 2 prime numbers—2 and 3.
2. n = 2 · 3 = 6
3.
1 2 3 4 5 6
4. x = 1. xn + 1 = 1 · 6 + 1 = 7. (x + 1)n = (1 + 1) · 6 = 12. Write 7 to 12 with 7 aligned with 1.
1 2 3 4 5 6 7 8 9 10 11 12
5. x = 2. xn + 1 = 2 · 6 + 1 = 13. (x + 1)n = (2 + 1) · 6 = 18. Write 13 to 18. Repeat for the next few lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
6 and 7. Sieving
12 3 4 5 6 78910 11 12 13141516 17 18 19202122 23 24 25262728 29 30
8. Sieving
12 3456789101112131415161718192021222324252627282930
9. Resultant list contains a non-prime 25. Use other methods of sieve to arrive at
2 3 5 7 11 13 17 19 23 29
Given a number k > n, we know that it is not prime if k mod n and n are not relatively prime. The fraction of numbers that the wheel sieve eliminates is 1 - phi (n) / n, which is also the efficiency of the sieve. From the properties of phi, it can easily be seen that the most efficient sieve smaller than x is the one where and . It can also be demonstrated that this efficiency rises very slowly for large n.
To be of maximum use on a computer, we want the numbers that are smaller than n and relatively prime to it as a set. Using a few observations, the set can easily be generated :
|